/*
 * @Author: sbotlp
 * @Email: sbotlp@sina.com
 * @Date: 2019-11-03 20:47:35
 * @LastEditTime: 2019-11-03 21:07:37
 * @Description: http://www.sbotlp.com.cn
 */
function loadImag(src) {
  return new Promise((resolve, reject) => {
    const img = document.createElement('img');
    img.onload = () => {
      resolve(img);
      // reject(11)
    }
    img.onerror = (e) => {
      reject(e)
    }
    img.src = src;
  })
}
const src = `https://api.sbotlp.com.cn/public/image/20190924/1569308973.png`;
const result= loadImag(src);
result.then(res => {
  console.log('res: ', res);
})
result.then(res =>{
  console.log('res.width: ', res.width);
},err => {
  console.log('err: ', err);
})
result.then(res =>{
  console.log('res.height: ', res.height); 
},err=>{
  console.log('err: ', err);
})
result.catch(err => {
  console.log('err: ', err);
})
async function getImgInfo (src) {
  try {
    const result1 = await loadImag(src);
    console.log('result1: ', result1);
  } catch (error) {
    console.log('error: ', error);
  }
}
getImgInfo(src);